<?php

namespace Tbf\Bundle\UploadBundle;

use Tbf\Component\FileSystem\FileSystemFunction;

class LocalFileSaver implements SaverInterface
{
    protected $save_path;
    protected $save_url;
    public function __construct($save_path,$save_url)
    {
        $this->save_path = $save_path;
        $this->save_url = $save_url;
    }
    /**
     * 把这个blob对象保存到文件系统里面,返回url绝对地址
     * 1.保存文件地址配置好了.由构造函数传入
     * 2.保存url地址配置好了.由构造函数传入
     * @param  BlobInterface $blob
     * @return url
     * @return error
     */
    public function save(BlobInterface $blob)
    {
        $err = $blob->saveToFilePath($this->save_path);
        if ($err!==null){
            return array(null,$err);
        }
        return array($this->save_url,null);
    }

}
